    #include <iostream>
    #include <vector>

    using namespace std;

bool isValidSubsequence(vector<int> array, vector<int> subsequece)
{
    // 返回 subsequence 是否为 array 的子序列
    vector<int> find;
    vector<int>::iterator ariter = array.begin();
    vector<int>::iterator subiter = subsequece.begin();

    while (subiter != subsequece.end() && ariter != array.end())
    {
        if (*subiter == *ariter)
        {
            find.push_back(*subiter);
            subiter++;
            continue;
        }

        ariter++;
    }

    return (subsequece == find);
}

bool isValidSubsequence_2(vector<int> array, vector<int> subsequece)
{
    // 返回 subsequence 是否为 array 的子序列
    vector<int> find;
    int ar_index = 0;
    int sub_index = 0;

    while (sub_index < subsequece.size() && ar_index != array.size())
    {
        if (subsequece[sub_index] == array[ar_index])
        {
            find.push_back(subsequece[sub_index]);
            sub_index++;
            continue;
        }

        ar_index++;
    }

    return (subsequece == find);
}

void decToBin(int i)
{
    // 把参数 i 转换成二进制并打印
    int shang = i / 2;
    int yushu = i % 2;

    if (shang == 0)
    {
        cout << yushu;
        return;
    }

    decToBin(shang);

    cout << yushu;
}

void insert_array()
{
    vector<int> array{1, 3, 5, 7, 9};
    vector<int> newArray;

    newArray.insert(newArray.end(), array.end() - 2, array.end());

    for (vector<int>::iterator iter = newArray.begin(); iter != newArray.end(); iter++)
    {
        cout << *iter << " ";
    }

    cout<<endl;

    for( auto &c : newArray)
    {
        cout << c << " ";
    }
}

int main(int argc, char const *argv[])
{
    cout << "11 老师的2021-09-12作业:" << endl;

    cout << "1、检查子数组:" << endl;
    vector<int> array = {1, 3, 4, 7, 9}, subsequece = {3, 7, 9};
    bool blnCheck = isValidSubsequence(array, subsequece);

    cout << "isValidSubsequence: " << blnCheck << endl;

    cout << "2、打印二进制:" << endl;
    int num = 8;
    cout << "decToBin(" << num << ") = ";
    decToBin(num);

    cout << endl;

    cout << "3、插入最后两个元素:" << endl;
    insert_array();

    return 0;
}
